<?php
require_once __DIR__ . '/vendor/autoload.php';

use KozyaxQrcode\QRcode;
use KozyaxQrcode\Uyghur;
use KozyaxQrcode\Poster;

// Example 1: Simple QR Code generation
echo "Generating QR Code...\n";
QRcode::png('ساالام ئەلەيكۇم دۇنيا!', 'example_qr.png');
echo "QR Code saved as example_qr.png\n";

// Example 2: Uyghur text processing
echo "\nProcessing Uyghur text...\n";
$uyghur = new Uyghur();
$originalText = 'ساالام ئەلەيكۇم';
$processedText = $uyghur->getUyPFStr($originalText);
echo "Original: $originalText\n";
echo "Processed: $processedText\n";

// Example 3: Create poster with Uyghur text
echo "\nCreating poster...\n";

// You need a background image for this example
$backgroundImage = 'background.jpg'; // Make sure this file exists

if (file_exists($backgroundImage)) {
    $config = [
        'bg_url' => $backgroundImage,
        'text2' => [
            [
                'text' => $processedText,
                'left' => 50,
                'top' => 100,
                'fontSize' => 30,
                'fontColor' => '255,255,255'
            ]
        ],
        'text3' => [
            [
                'text' => 'Hello World',
                'left' => 50,
                'top' => 200,
                'fontSize' => 24,
                'fontColor' => '255,0,0'
            ]
        ]
    ];

    Poster::setConfig($config);
    if (Poster::make('example_poster.png')) {
        echo "Poster saved as example_poster.png\n";
    } else {
        echo "Error creating poster: " . Poster::getErrMessage() . "\n";
    }
} else {
    echo "Background image '$backgroundImage' not found. Skipping poster example.\n";
}

echo "\nExample completed!\n";